package com.study.hot.jetpack.livedata;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
 * <pre>
 *     author : fauks
 *     time   : 2020/03/29
 *     desc   :
 * </pre>
 */
public class ScoreViewModel extends ViewModel {
    private MutableLiveData<Integer> aScore;
    private MutableLiveData<Integer> bScore;

    public MutableLiveData<Integer> getaScore() {
        if (aScore == null) {
            aScore = new MutableLiveData<>();
            aScore.setValue(0);
        }
        return aScore;
    }

    public MutableLiveData<Integer> getbScore() {
        if (bScore == null) {
            bScore = new MutableLiveData<>();
            bScore.setValue(0);
        }
        return bScore;
    }

    public void addAScore(int score) {
        aScore.setValue(aScore.getValue() + score);
    }

    public void addBScore(int score) {
        bScore.setValue(bScore.getValue() + score);
    }
}
